# coding:utf-8

# Which saves money for calculating public transport card and Alipay discount card?
# 计算公交卡和支付宝折扣卡哪个省钱

import datetime


def compute_cost():
    half_transfer = True  # 公交地铁换乘
    now_date = datetime.datetime.today().date()
    # now_date = datetime.date(2021, 12, 6)
    now_hour = datetime.datetime.today().time().hour
    # end_date = datetime.date(2121, 12, 31)

    ali_card_bus_cost = 1.4    # ali bus 07 card
    ali_card_metro_cost = 2.4  # ali metro 07 card
    ali_bus_discount = 0.7    # 阿里卡片折扣
    ali_metro_discount = 0.7  # 阿里卡片折扣

    fee_bus_one = 8
    fee_metro_one = 4
    ali_max_bus = 1 if fee_bus_one * (1-ali_bus_discount) > 1 else fee_bus_one * (1-ali_bus_discount)
    ali_max_metro = 1.5 if fee_metro_one * (1-ali_metro_discount) > 1.5 else fee_metro_one * (1-ali_metro_discount)
    ali_fee_bus_one = fee_bus_one - ali_max_bus
    ali_fee_metro_one = fee_metro_one - ali_max_metro

    total_times = 2
    if now_hour > 12:
        total_times = 1
    add_day = 1
    while True:
        next_day = now_date + datetime.timedelta(days=add_day)
        total_times += 2
        add_day += 1
        if next_day.isoweekday() >= 5:
            break

    total_cost = (fee_bus_one + fee_metro_one) * total_times
    if half_transfer:
        total_cost = total_cost - 1 * total_times
    bus_card_cost = (fee_bus_one + fee_metro_one - 1) * total_times
    ali_card_cost = (ali_fee_bus_one + ali_fee_metro_one) * total_times + ali_card_bus_cost + ali_card_metro_cost
    if bus_card_cost > ali_card_cost:
        print('ali', (bus_card_cost - ali_card_cost))
    else:
        print('bus', (ali_card_cost - bus_card_cost))
    # print(total_times)


if __name__ == "__main__":
    compute_cost()

